﻿<########################################################################################################
	
	.AUTHOR
		Rahul G. Babar																		 
	
	.SYNOPSYS
		Deletes all web applications in a local farm except central administration web application
	
	.DESCRIPTION
	    Deletes all web applications in a local farm except central administration web application
		
	.EXAMPLE
		.\DeleteAllWebApplications.ps1			 

    
########################################################################################################>

# Get-SPWebApplication returns all the application except central administration
# unless you have specified switch -IncludeCentralAdministration

$webApplications = Get-SPWebApplication

foreach($webApplication in $webApplications)
{
	$webApplication.UnprovisionGlobally($true);
	foreach($contentDatabase in $webApplication.ContentDatabases)
	{
		$contentDatabase.Unprovision();
	}
	$webApplication.Delete();
}